function largestPrimeFactor(number) {
    let k = 1;
    while (number > 1) {
        ++k;
        while (number % k === 0) {
            number /= k;
        }
    }
    return k;
}

console.log(largestPrimeFactor(13195));